<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ page import="com.scalar.chiptrack.commons.Constants" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/inventoryps.do"/>
<%
	String chipTracContext = "/" + ConfigManager.getChipTracContext();
    String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
%>
<html:html locale="true">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<script language="javascript">
var dateElement = "";
function openCalendar( dateValue )
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.focus();
}

function assignDate( passedValue )
{
    dateElement.value=passedValue;
    window.focus();
}

function enableDieQtyOutField( index )
{
    var form                    = document.inventoryPackingSlipForm;
    if( form['selectedLotsList['+index+'].checked'].checked == true )
    {
		if(  typeof  form['selectedLotsList['+index+'].dieQtyIn'] == "undefined" )
		{
			form['selectedLotsList['+index+'].shipQty'].value  = form['selectedLotsList['+index+'].waferQtyIn'].value;
			form['selectedLotsList['+index+'].checkedWaferIdsAsString'].value  = form['selectedLotsList['+index+'].waferIds'].value;

		}
		else
		{
			form['selectedLotsList['+index+'].shipQty'].value  = form['selectedLotsList['+index+'].dieQtyIn'].value;
            if (form.processType.value.toUpperCase() !=  'Die Bank'.toUpperCase() )
            {
                form['selectedLotsList['+index+'].shipQty'].disabled = false;
                form['selectedLotsList['+index+'].shipQty'].focus();    
            }

		}

	}
	else
	{
		form['selectedLotsList['+index+'].shipQty'].disabled = true;
		form['selectedLotsList['+index+'].shipQty'].value  = 0;
	}
}
function dieBankWaferEntry( rowIndex )
{
    var pa=document.getElementById("message");
    pa.innerHTML    = '';
    var form        = document.inventoryPackingSlipForm;

    newWindow = window.open('<%=chipTracContext%>/jsp/operations/inventory_packing_slip_die_bank_wafer_entry.jsp?rowIndex=' + rowIndex,'dieBankWaferPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=375,resizable=yes');
    newWindow.focus();
}
function waferDataEntry( rowIndex )
{
    var form = document.inventoryPackingSlipForm;
    var waferQtyInCtrl = form['selectedLotsList['+rowIndex+'].waferQtyIn'];
    
    newWindow = window.open('<%=chipTracContext%>/jsp/operations/inventory_packing_slip_wafer_entry.jsp?waferQty='+waferQtyInCtrl.value + '&rowIndex=' + rowIndex , 'OutTransactionWaferPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,scrollbars=yes,width=600,height=375,resizable=yes');
    newWindow.focus();
}

function save()
{
   var pa=document.getElementById("message");
    pa.innerHTML                = '';

    var form                    = document.inventoryPackingSlipForm;
    var count1                  = 0;
    for( var i=0; i < listSize; i++ )
    {
        if( form['selectedLotsList['+i+'].checked'].checked == true  )
        {
            var shipQty=0;

            if ( form['selectedLotsList['+i+'].shipQty'] != null )
            {
                if ( isNaN( parseInt( form['selectedLotsList['+i+'].shipQty'].value ) ) )
                {
                     shipQty = 0;
                     form['selectedLotsList['+i+'].shipQty'].value = shipQty;
                }
                else
                {
                      shipQty =  parseInt( form['selectedLotsList['+i+'].shipQty'].value );
                }
            }
            else
            {
                 shipQty = 0;
                 form['selectedLotsList['+i+'].shipQty'].value = shipQty;
            }
            if (form.baseprocessType.value.toUpperCase() == 'FAB'.toUpperCase() || form.baseprocessType.value.toUpperCase() == 'Wafer Store'.toUpperCase()
                || form.baseprocessType.value.toUpperCase() == 'Sort'.toUpperCase() || form.baseprocessType.value.toUpperCase() == 'Die Bank'.toUpperCase() 
                || form.processType.value.toUpperCase() == 'Back Grind'.toUpperCase()    )
            {
                if ( form['selectedLotsList['+i+'].waferIds'].value == '' && form['selectedLotsList['+i+'].checkedWaferIdsAsString'].value == '')
                {
                   pa.innerHTML = "<li>Please select the waferIds for <font color='blue'> " + form['selectedLotsList['+i+'].lotNumber'].value + "</font>";

                   return;
                }
            }
            
            if( shipQty  == 0 )
            {
                pa.innerHTML = "<li> Zero Qty was not allowed:";
                form['selectedLotsList['+i+'].shipQty'].focus();
                return;
            }
            form['selectedLotsList['+i+'].shipQty'].disabled = false;
            count1++;
        }
    }

    if( count1==0 )
	{
		pa.innerHTML = "<li> Please select atleast one lot";
		return;
	}

    form.action.value = "save";
    form.submit();

}

</script>
<!-- Top Header Start-->
<logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
	<%@ include file="/jsp/includes/header.jsp" %>
</logic:equal>
<logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
	<%@ include file="/jsp/includes/extHeader.jsp" %>
</logic:notEqual>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 border="0" width="100%">
	<TBODY>
	<TR>
		<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
		<!-- Side Navigation start -->
	    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
		    <%@ include file="/jsp/operations/dataentryMenu.jsp" %>
		</logic:equal>
		<logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
			<%@ include file="/jsp/operations/ext_user_dataentryMenu.jsp" %>
		</logic:notEqual>
		<!-- end of the side navigations -->
		<TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
		<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
		<TD valign="top" width="100%"  align=center>	 
			<BR>
			<html:form name="inventoryPackingSlipForm" method = "POST"  type="com.scalar.chiptrack.operations.inventoryps.forms.InventoryPackingSlipForm" action="/inventoryps" >
			<input type="hidden" name="action" value="<%= (String)request.getAttribute("action")%>">
			<TABLE border="0" width="100%" align="center">
				<TR><TD colspan=6 class="NArialW" align="center">Inventory Packing Slip</TD></TR>
				<TR><TD colspan=6>&nbsp;</TD></TR>
							<TR><TD colspan=6 class='NArialL'><strong><FONT id="message" styleClass="NArialL" color='FF0000'></FONT></strong></TD></TR>
				<TR><TD colspan=6>
				<chiptrack:info  styleClass="NArialL" />
				<chiptrack:errors styleClass="NArialL" />
				<chiptrack:messages type="info" styleClass="NArialL" />
				</TD>
				</TR>
				<logic:equal name="showMessage" value="TRUE">
						<tr><td colspan=6 align='left'><font class='NArialS'color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></TD></TR>
				</logic:equal>

			<TR>
				<TD>
					<TABLE  border="0" width="100%" cellpadding="1" cellspacing="1" align=center>
						<tr>
							<td colspan="6"  class="NArialL"><FONT id="errors" color="FF0000"></FONT></td>
						</tr>
						<tr>
							<td width="21%"><font class="NArialL">PackingSlip Number:</font></td>
							<td width="21%">
								<html:text disabled="true" name="inventoryPackingSlipForm"  property="packingSlipNumber" size="20" maxlength="50" styleClass="disabledtxfield"/>
								<html:hidden name="inventoryPackingSlipForm"  property="packingSlipNumber"/>
								<html:hidden name="inventoryPackingSlipForm"  property="packingSlipId"/>
                                <html:hidden name="inventoryPackingSlipForm"  property="processType"/>
                                <html:hidden name="inventoryPackingSlipForm"  property="baseprocessType"/></td>
							<td width="3%">&nbsp;</td>
							<td width="21%">&nbsp;</td>
							<td width="21%">&nbsp;</td>
							<td width="3%">&nbsp;</td>
						</tr>
						<tr>
							<td width="21%"><font class="NArialL">From Location:</font></td>
							<td width="21%"><html:text disabled="true" name="inventoryPackingSlipForm"  property="fromVendorName" size="20" styleClass="disabledtxfield"/></td>
							<html:hidden name="inventoryPackingSlipForm"  property="fromVendorName"/>
							<html:hidden name="inventoryPackingSlipForm"  property="locationId"/>
							<td width="3%">&nbsp;</td>
							<td width="21%"><font class="NArialL">To Location:</font></td>
							<td width="21%"><html:text disabled="true" name="inventoryPackingSlipForm"  property="toVendorName" size="20" styleClass="disabledtxfield"/></td>
							<html:hidden name="inventoryPackingSlipForm"  property="toVendorName"/>
							<html:hidden name="inventoryPackingSlipForm"  property="toVendorId"/>
							<td width="3%">&nbsp;</td>
						</tr>
						<tr>
							<td width="21%"><font class="NArialL">From Address:</font></td>
							<td width="21%"><html:textarea disabled="true" rows="12" name="inventoryPackingSlipForm" property="fromAddressAsString" cols="30" styleClass="disabledtxfield"/></td>
							<td width="3%">&nbsp;</td>
							<td width="21%"><font class="NArialL">To Address:</font></td>
							<td width="21%"><html:textarea disabled="true" rows="12" name="inventoryPackingSlipForm" property="toAddressAsString" cols="30" styleClass="disabledtxfield"/></td>
							<td width="3%">&nbsp;</td>
						</tr>
						<tr>
							<td width="21%"><font class="NArialL">No of boxes:</font></td>
							<td width="21%"><html:text name="inventoryPackingSlipForm" property="noOfBoxes" styleClass="txfield" size="20" maxlength="8" /></td>
							<td width="3%">&nbsp;</td>
							<td width="21%"><font class="NArialL">Gross Weight:</font></td>
							<td width="21%"><html:text name="inventoryPackingSlipForm" property="grossWeight" styleClass="txfield" size="20" maxlength="8" /><font class="NArialL"> Lbs</font></td>
							<td width="3%">&nbsp;</td>
						</tr>
						<tr>
							<td width="21%"><font class="NArialL">Ship Date:</font></td>
							<td width="21%"><html:text name="inventoryPackingSlipForm" property="shipDate" styleClass="txfield" size="20" maxlength="10" />
								   <a href="javascript:openCalendar( document.inventoryPackingSlipForm.shipDate )">
										<img onMouseOver="window.status='Click  to select date';return true" onMouseout="window.status='';return 	true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20>
									</a></td>
							<td width="3%">&nbsp;</td>
							<td width="21%"><font class="NArialL">Waybill No:</font></td>
							<td width="21%"><html:text name="inventoryPackingSlipForm" property="wayBillNo" styleClass="txfield" size="20" maxlength="15" /></td>
							<td width="3%">&nbsp;</td>
						</tr>
                        <TR>
                            <TD COLSPAN="6"><IMG SRC="<%=chipTracContext%>/jsp/includes/images/spacer.gif" HEIGHT=5></TD>
                        </TR>

                        <tr>
                            <td width="21%" class="NArialL">Special Instructions:</td>
							<td colspan="5" class="NArialL"><html:textarea property="splInstructions" name="inventoryPackingSlipForm" styleClass="txfield" rows="4" cols="80"/></td>
						</tr>
                        
					</TABLE>
				</TD>
			</TR>
			<TR>
				<TD>
						<table width="100%" align="left" cellpadding="2" cellspacing="2" border="0">
							 <TR>
								<TD COLSPAN="9"><IMG SRC="<%=chipTracContext%>/jsp/includes/images/spacer.gif" HEIGHT=20></TD>
							</TR>

							<TR bgcolor="#993333" align = "left">
								<td class='NArialL' nowrap colspan="10"><font color="#FFFFFF">Lot Information</font></td>
							</TR>
							<nested:present property="selectedLotsList">
							<nested:size id="LotsSize" property="availableLotsList"/>
							<tr bgcolor="#993333" align = "center">
								<td class='NArialL'><font color="#FFFFFF">Select </font></td>
								<td class='NArialL' nowrap><font color="#FFFFFF">Part Number</font></td>
								<td class='NArialL' nowrap><font color="#FFFFFF">Lot No#</font></td>
								<td class='NArialL' nowrap><font color="#FFFFFF">FabLot No#</font></td>
								<td class='NArialL'><font color="#FFFFFF">Vendor</font></td>
								<td class='NArialL'><font color="#FFFFFF">Date In</font></td>
								<%--<td class='NArialL'><font color="#FFFFFF">Qty In</font></td>--%>
								<logic:equal name="showWaferIds" value="TRUE">
                                    <td class='NArialL'><font color="#FFFFFF">Wafer Qty</font></td>
                                    <td class='NArialL'><font color="#FFFFFF">Die Qty</font></td>
									<td class='NArialL'><font color="#FFFFFF">Wafer Ids</font></td>
								</logic:equal>
                                <logic:notEqual name="showWaferIds" value="TRUE">
                                <td class='NArialL'><font color="#FFFFFF">Die Qty</font></td>
                                </logic:notEqual>
								<td class='NArialL'><font color="#FFFFFF">Ship Qty </font></td>
							</tr>
						    <nested:size id="listSize" property="selectedLotsList"/>
                                
							<nested:iterate id="lotDetails" property="selectedLotsList" indexId="iterateIdx" type = "com.scalar.chiptrack.operations.dataentry.LotDetails">

							<tr bgcolor='<%=iterateIdx.intValue() % 2 == 0 ? "#FFFFEE" : "#DEE1E2"%>'>
					             <% String selectBox = "enableDieQtyOutField('" + iterateIdx.intValue() + "')"; %>
								<td width ="3%" align="center" class='NArialL' ><nested:checkbox  name="lotDetails" property ="checked" onclick="<%= selectBox %>" /></td>
								<td class='NArialL'><nested:write name="lotDetails" property ="partNumber"/></td>
								<td class='NArialL'><nested:write name="lotDetails" property ="lotNumber"/></td>
								<td class='NArialL'><nested:write name="lotDetails" property ="fabLotNumber"/></td>
								<td class='NArialL'><nested:write name="lotDetails" property ="vendorName"/></td>
								<td class='NArialL'><nested:write name="lotDetails" property ="dateIn"/></td>
							<logic:equal name="showWaferIds" value="TRUE">
                                <logic:equal value="Die Bank" property="processType" name="lotDetails">
                                    <td class='NArialL'nowrap><nested:write name="lotDetails" property ="waferQtyIn"/></td>
                                    <td class='NArialL'nowrap><nested:write name="lotDetails" property ="dieQtyIn"/></td>
                                         <nested:hidden name="lotDetails" property ="dieQtyIn"/>
                                         <nested:hidden property="binQtyAsString"/>
                                        <nested:hidden property="checkedBinQtyAsString"/>
                                        <nested:hidden property="waferChecked"/>
                                </logic:equal>
                                <logic:notEqual value="Die Bank" property="processType" name="lotDetails">
								    <td class='NArialL'><nested:write name="lotDetails" property ="waferQtyIn"/></td>
                                    <td class='NArialL'><nested:write name="lotDetails" property ="dieQtyIn"/></td>
									<nested:hidden name="lotDetails" property ="waferQtyIn"/>
                                </logic:notEqual>
							</logic:equal>
							<logic:notEqual name="showWaferIds" value="TRUE">
								<td class='NArialL'><nested:write name="lotDetails" property ="dieQtyIn"/></td>
								<nested:hidden name="lotDetails" property ="dieQtyIn"/>
							</logic:notEqual>

							<logic:equal name="showWaferIds" value="TRUE">
								<td class='NArialL'><nested:write name="lotDetails"  property ="waferIds" /></td>
								<nested:hidden name="lotDetails" property ="waferIds"/>
								<nested:hidden name="lotDetails" property="checkedWaferIdsAsString"/>
							</logic:equal>
							<td class='NArialL'><nested:text  name="lotDetails"  property ="shipQty"  styleClass="valuetxfield" size="8" onkeypress="javascript:allowInteger()" disabled="true" />
							<logic:equal name="showWaferIds" value="TRUE">
                            <logic:equal value="Die Bank" property="processType" name="lotDetails">
                                <a href="javascript:dieBankWaferEntry('<%= iterateIdx.intValue() %>')" onmouseover="window.status='Click here to view the Wafer Id Info';return true" onmouseout="window.status='';return true" title="Wafer Information"><IMG border="0" src="<%=chipTracContext%>/jsp/includes/images/uparrow.gif" width="20" height="16"></a>
                            </logic:equal>
                            <logic:notEqual value="Die Bank" property="processType" name="lotDetails">
							    <a href="javascript:waferDataEntry('<%= iterateIdx.intValue() %>')" onmouseover="window.status='Click here to view the Wafer Id Info';return true" onmouseout="window.status='';return true" title="Wafer Information"><IMG border="0" src="<%=chipTracContext%>/jsp/includes/images/uparrow.gif" width="20" height="16"></a>
                            </logic:notEqual>
							</logic:equal>
							</td>
                            <nested:hidden name="lotDetails" property ="lotNumber"/>
							<nested:hidden property="processStepId"/>
							<nested:hidden property="lotId"/>
						</tr>
						</nested:iterate>
						<script type="text/javascript">
						   listSize = <%=listSize.intValue()%>;
						</script>
						</nested:present>
						 <TR>
							<TD COLSPAN="13"><IMG SRC="<%=chipTracContext%>/jsp/includes/images/spacer.gif" HEIGHT=20></TD>
						</TR>
						<tr>
						   <td align = "center" colspan ="13">
								<a href="javascript:save()" onmouseover="window.status='Click here save Inventory Packing Slip';return true" onmouseout="window.status='';return true" title="Click here to save Inventory Packing Slip"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<a href="javascript:reset()" onmouseover="window.status='Click here to Reset Inventory Packing Slip';return true" onmouseout="window.status='';return true" title="Click here to Reset Inventory Packing Slip"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
							</td>
						</tr>
						</table>
					</TD>
				</TR>
               </TABLE>
		</html:form>
		<BR><BR><BR>
	    </TD>
		<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
	</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</html:html>